package com.example.rpcconsumer;

import com.example.rpccommon.model.User;
import com.example.rpccommon.service.UserService;
import com.example.rpc_core.proxy.ServiceProxyFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 简易服务消费者示例
 */
@SpringBootApplication
public class RpcConsumerApplication {

    /**
     * 简易服务消费者示例
     */
    public static void main(String[] args) throws Exception {
        // todo 需要获取 UserService 的实现类对象
        // 动态代理
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);

        User user = new User();
        user.setName("tangMouMou");
        // 调用
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getName());
        } else {
            System.out.println("user == null");
        }

        short number = userService.getNumber();
        System.out.println(number);


        short number2 = userService.getNumber();
        System.out.println(number2);

    }


}
